﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BMManage
{
    public partial class FormUserAdd : Form
    {
        public FormUserAdd()
        {
            InitializeComponent();
        }

        private void FormUserAdd_Load(object sender, EventArgs e)
        {
            BMWebService.BMWebService srv = new BMWebService.BMWebService();
            var data = srv.AddAreaName("苏州","1");
            foreach (BMWebService.DataSetDB.AREASRow item in data)
            {
                this.comboBox1.Items.Add(item.AREANAME);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.comboBox1.Text.Trim() == "")
            {
                MessageBox.Show("区域不能为空");
                return;
            }
            if (txtPwd.Text.Trim() == "")
            {
                MessageBox.Show("信息不能为空");
                return;
            }
            if (txtLogin.Text.Trim() == "")
            {
                MessageBox.Show("信息不能为空");
                return;
            }
            if (txtName.Text.Trim() == "")
            {
                MessageBox.Show("信息不能为空");
                return;
            }
            BMWebService.DataSetDB.USERSDataTable dt = new BMWebService.DataSetDB.USERSDataTable();
            dt.AddUSERSRow(txtLogin.Text.Trim(), txtPwd.Text.Trim(), txtName.Text.Trim(), comboBox1.Text);

            BMWebService.BMWebService srv = new BMWebService.BMWebService();
            var data = srv.AddUser(dt);
            foreach (BMWebService.DataSetDB.USERSRow item in data)
            {
                if (item.LOGINNAME == txtLogin.Text.Trim())
                {
                    MessageBox.Show("添加成功");
                    this.Close();
                    return;

                }
            }
            MessageBox.Show("添加失败");

        }
    }
}
